package com.viphuli.fragment;

import java.util.List;

import android.support.v4.app.Fragment;
import android.text.Html;
import android.widget.TextView;
import butterknife.Bind;

import com.offroader.utils.StringUtils;
import com.viphuli.app.R;

public class HomeServiceInfoIntroduceFragment extends BaseProgressFragment {

	@Bind(R.id.id_main_home_service_item_info_introduce)
	protected TextView introduceText;

	private String introduce;

	@Override
	protected int obtainContentRes() {
		return R.layout.frag_home_service_introduce;
	}

	@Override
	protected void initParams() {

	}

	@Override
	protected void initView() {

//		introduceText.setMovementMethod(ScrollingMovementMethod.getInstance());

		if (StringUtils.isNotBlank(introduce))
			introduceText.setText(introduce);
	}

	@Override
	protected void initData() {
		List<Fragment> fs = getFragmentManager().getFragments();
		HomeServiceInfoFragment serviceInfoFrag = (HomeServiceInfoFragment) fs.iterator().next();

		if (serviceInfoFrag.getItemPage() != null) {
			String introduce = serviceInfoFrag.getItemPage().getIntroduction();
			if (StringUtils.isNotBlank(introduce))
				introduceText.setText(Html.fromHtml(introduce));
		}
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;

		if (StringUtils.isNotBlank(introduce))
			introduceText.setText(Html.fromHtml(introduce));
	}

}
